import request from '../utils/request';

export function orgList() {
  return request('api/auth/v1.0/org/list');
}

export async function query(params) {
  return request(`api/auth/v1.0/org?id=${params}`);
}

export async function addOrganization(params,flag) {
  const method = flag ==='update'?'PUT':'POST';
  return request(`api/auth/v1.0/org?id=${params.id}`, {
    method: method,
    body: {
      ...params,
      method: method,
    },
  });
}

export async function deleteOrg(params) {
  return request(`api/auth/v1.0/org?id=${params}`,{
    method:'DELETE'
  });
}

export async function addDepartment(params,flag) {
  const method = flag ==='update'?'PUT':'POST';
  return request(`api/auth/v1.0/org?id=${params.id}`, {
    method: method,
    body: {
      ...params,
    },
  });
}

export async function addUser(params) {
  return request(`api/auth/v1.0/org/user`, {
    method: 'POST',
    body: {
      ...params,
    },
  });
}

export async function deleteUser(params) {
  return request(`api/auth/v1.0/org/user?${params}`,{
    method:'DELETE'
  });
}